<?php
class markethasneighborhooddao extends CI_Model{
	function __construct()
	{
		// Call the Model constructor
		parent::__construct();
	}

	public function getbyid($market_id, $neighborhood_id){
		$this->db->select('*');
		$this->db->from('market_has_neighborhood');
		$this->db->where('market_id',$market_id);
		$this->db->where('neighborhood_id',$neighborhood_id);
		$query = $this->db->get();
		$res = $query->row();
		return $res;
	}
	
	public function get_all(){
		$this->db->select('*');
		$this->db->from('market_has_neighborhood');
		$query = $this->db->get();
		$res = $query->result();
		return $res;
	}
	
	public function insert($market_id,$neighborhood_id,$market_branch_phone){
		$data = array(
				'market_id' => $market_id,
				'neighborhood_id' => $neighborhood_id,
				'market_branch_phone' => $market_branch_phone
		);
		$str = $this->db->insert_string('market_has_neighborhood', $data);
		$res = $this->db->query($str);
		return $res;
	}
	
	public function del($market_id, $neighborhood_id) {
		if (intval($market_id) > 0 && intval($neighborhood_id) > 0) {
		$this->db->where('market_id',$market_id);
		$this->db->where('neighborhood_id',$neighborhood_id);
		$this->db->delete('market_has_neighborhood');
		return ($this->db->affected_rows() == 1) ? TRUE : FALSE;
		}
		return false;
	}
}
?>